#ifndef SIXMAP_HH_
#define SIXMAP_HH_

#include <sys/types.h>
#include "fivetuple.hh"
#include <lagniappe/Mutex.h>
#include <boost/shared_ptr.hpp>

class SixMap
{
  lagniappe::Mutex * mutex;
  tt::SixFiveTuple core;
  uint32_t count;
  bool set;
public:
  SixMap(lagniappe::Mutex * m) : mutex(m), count(0), set(false) {}
  void setCore(tt::SixFiveTuple & ft) {
    mutex->lock();
    core = ft;
    count++;
    set = true;
    mutex->notifyAll();
    mutex->unlock();
  }
  tt::SixFiveTuple getCore() {
    mutex->lock();
    while(!set) {
      mutex->wait();
    }
    count++;
    mutex->unlock();
    return core;
  }
  uint32_t getCount() {
    mutex->lock();
    while(!set) {
      mutex->wait();
    }
    int ret = count;
    mutex->unlock();
    return ret;
  }
    
};

typedef boost::shared_ptr<SixMap> SixMap_p;

#endif // SIXMAP_HH_
